package cn.com.dcsgo.config;

import org.springframework.web.servlet.support.AbstractAnnotationConfigDispatcherServletInitializer;

/**
 * 应用程序初始化类
 * 两个IoC容器 WebIoC ServiceIoC
 * ServiceIoC作为Root IoC容器
 * WebIoC作为子IoC容器
 * WebIoC可以访问ServiceIoC但ServiceIoC不能访问WebIoC
 *
 * @author Dcsgo
 * @since 2025/3/7 17:32
 */

public class ApplicationInitializer extends AbstractAnnotationConfigDispatcherServletInitializer {

    /**
     * ServiceIoC容器
     * 服务层和持久层配置类
     *
     * @return Class[]
     */
    @Override
    protected Class<?>[] getRootConfigClasses() {
        return new Class[]{ServiceConfig.class, MapperConfigAllJava.class, DataSourceConfig.class};
    }

    /**
     * WebIoC容器
     * 控制器层配置类
     *
     * @return Class[]
     */
    @Override
    protected Class<?>[] getServletConfigClasses() {
        return new Class[]{WebMvcConfig.class};
    }

    /**
     * dispatcherServlet 拦截路径
     *
     * @return String[]
     */
    @Override
    protected String[] getServletMappings() {
        return new String[]{"/"};
    }
}
